﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

  <BorderGapMaskConverter x:Key="BorderGapMaskConverter" />
  <Style TargetType="{x:Type GroupBox}">
    <Setter Property="BorderBrush" Value="#D5DFE5" />
    <!-- Changed BorderThickness to 0 to show only header of groupbox -->
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <Grid SnapsToDevicePixels="true">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="6" />
              <ColumnDefinition Width="Auto" />
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="6" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="*" />
              <RowDefinition Height="6" />
            </Grid.RowDefinitions>

            <!-- Background color of complete control except header Replace LightBrush with WindowBackgroundBrush-->
            <Border Grid.ColumnSpan="4" Grid.RowSpan="4"
                    Background="{DynamicResource WindowBackgroundBrush}" CornerRadius="4,4,4,4" BorderThickness="1,1,1,1" />
            
            <Border Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3" BorderThickness="1,1,1,1" CornerRadius="4"
                    BorderBrush="{DynamicResource NormalBorderBrush}">
              <Border.OpacityMask>
                <MultiBinding Converter="{StaticResource BorderGapMaskConverter}" ConverterParameter="7">
                  <Binding Path="ActualWidth" ElementName="Header" />
                  <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
                  <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
                </MultiBinding>
              </Border.OpacityMask>
              <Border BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                <Border.BorderBrush>
                  <SolidColorBrush Color="{DynamicResource MainColor}" />
                </Border.BorderBrush>
                <Border BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
                  <Border.BorderBrush>
                    <SolidColorBrush Color="{DynamicResource MainColor}" />
                  </Border.BorderBrush>
                </Border>
              </Border>
            </Border>
            <Border Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" Grid.RowSpan="3"
                    Background="{TemplateBinding Background}"
                    BorderBrush="Transparent"
                    BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" />
            
            <Border Grid.ColumnSpan="4" Grid.RowSpan="2"
                    Background="{DynamicResource NormalBrush}"
                    BorderThickness="1,1,1,0" CornerRadius="2,2,0,0" x:Name="Main"
                    BorderBrush="{DynamicResource NormalBorderBrush}" />

            <Rectangle x:Name="Shine" Opacity="1" Stroke="{x:Null}" RadiusX="3" RadiusY="3"
                       VerticalAlignment="Stretch" Height="Auto" Grid.ColumnSpan="4" Grid.RowSpan="2" Margin="1,1,1,1">
              <Rectangle.Fill>
                <LinearGradientBrush EndPoint="0.5,0.971" StartPoint="0.5,0.042">
                  <GradientStop Color="#26FFFFFF" Offset="0" />
                  <GradientStop Color="#00FFFFFF" Offset="1" />
                  <GradientStop Color="#26FFFFFF" Offset="0.467" />
                  <GradientStop Color="#00FFFFFF" Offset="0.475" />
                </LinearGradientBrush>
              </Rectangle.Fill>
            </Rectangle>

            <Border x:Name="Header" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Padding="3,1,3,0">
              <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                ContentSource="Header"
                                RecognizesAccessKey="True"
                                Margin="0,4,0,4" />
            </Border>

            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Margin="{TemplateBinding Padding}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="2" />
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Foreground">
      <Setter.Value>
        <SolidColorBrush Color="{DynamicResource WhiteColor}" />
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>